<template>
  <div class="app">
	  <Tabbar :leftText="$t('textTrans.贸易')"></Tabbar>
	  <div class="apphome">
            <div>
				<div>+ {{accountdata.rate}}% TRX</div>
				<!--<img src="../../assets/imgs/home/may1.png" style="width: 80%;height: 190px;margin: 20px 0;" >-->
				<div style="font-size: 15px;font-weight: 550;">{{ $t("textTrans.标题二") }}</div>
			</div>
  	  </div>
  <van-cell style="background: transparent;color: #fff;" @click='$router.push({name:"incomet"})' :value="$t('textTrans.查看全部')" is-link>
				<template #title>
				<span class="custom-title">{{ $t("textTrans.交易利润") }}</span>
				</template>
			</van-cell>
			<div style="padding-bottom: 80px;" class="back">
				<div v-for="item in data" :key='item.id' style="border-radius: 10px;margin: 6px auto; width: 82%; display: flex;align-items: center;justify-content: space-between;padding: 15px;background: #F7F7F7;">
					<div >
						<div style="color:rgb(255, 109, 0)">{{item.account}}TRX</div>
						<div style="color: gray;margin-top: 8px;">{{ $t("textTrans.量化交易收入") }}</div>
					</div>
					<van-button @click='getRecev(item.id)' :disabled="item.status==1" style="padding: 4px 8px;" round type="primary" :color='item.status==0?"#00A170":"gray"' size="mini">
						{{item.status==0 ? $t("textTrans.赎回"):$t("textTrans.已结束")}}
					</van-button>
				</div>
			</div>
  </div>
</template>
<script>
import { Dialog,Sticky } from "vant";
	import {
		projectRate,
		projectreceive,
		basicRecord
	} from "@/api/home";
import { currencyBill,goodsorderList,payOrder } from "@/api/home";
import { backpage } from "@/utils/backPage";
import { getParams } from "@/utils/getParams";
export default {
  data() {
    return {
      currency_id: "",
      active: 0,
	  data:[],
	  accountdata:{},
      currencyInfo: { data: [] }
    };
  },
  mounted() {
	this.getData()
	projectRate().then(res=>{
		this.accountdata=res
	})
  },
  methods: {
	  getRecev(id){
		  projectreceive({id}).then(res=>{
			  console.log(res)
			  this.getData()
		  })
	  },
	  topay(item){
		  Dialog.alert({
		    message: 'Confirm payment？',
			confirmButtonText:'Confirm',
		  }).then(() => {
			  payOrder({order_id:item.id}).then(res=>{
				  window.location.reload()
			  })
		    // on close
		  });
	  },
    onClickLeft() {
      backpage();
    },
    rightClick() {
      this.$router.push({
        name: "NoticeList"
      });
    },
    // 兑换
    toChange() {
      this.$router.push({ path: "exchange", query: { id: this.currency_id } });
    },
    // 转入
    toBill() {
      this.$router.push({ path: "Coin_bill", query: { id: this.currency_id } });
    },
    getData() {
		basicRecord({page:1,pagesize:10}).then(res=>{
			this.data=res.data
		})
    },
    tabClick(name) {
      this.active = name;
      this.getData();
    },
    // 提现
    toWithdraw() {
      this.$router.push({
        path: "currency_withdraw",
        query: { id: this.currency_id, currency_name: this.currencyInfo.name }
      });
    }
  }
};
</script>
<style lang="less" scoped>
	.back{
		background: url('../../assets/imgs/home/background.png') no-repeat;
		background-size: 100% 100%; 
	}
	.app{
		width: 100%;
		height: 100%;
		background: url('../../assets/imgs/home/background.png') no-repeat;
		background-size: 100% 100%; 
		// background: white;
		font-size: 14px;
	}
		
	.apphome{
		margin: 20px;
		border-radius: 15px;
		padding: 20px;
		text-align: center;
		background: #B5F3EA;
	}
	/deep/.van-cell__value{
		color: #fff;
	}

</style>
